﻿@using FutureUser = FutureApp.Users.User
@model FutureApp.Users.Dto.UserEntityDto

@section Scripts{
    <script>
	    !function($) {
		    var $$$ = function() {
			    this.$box = $('.box');
			    this.$form = $('form');
			    this.service = abp.services.app.user;
                this.localize = abp.localization.localize;
		    };
		    $$$.prototype = {
		        init: function () {
		            this.formSubmit();
		            this.binding();
		        },
		        formSubmit: function () {
		            this.$form.submit(function (e) {
		                e.preventDefault();
		            });
		        },
			    binding: function() {
			        var self = this;
			        self.$box.on("click", '.btn', function (e) {
			            e.preventDefault();

			            var $sender = $(e.currentTarget);
			            var action = $.trim($sender.data("action"));
			            switch (action) {
			                case "submit":
			                    self.submit();
			                    break;
			            }
			        });
			    },
			    submit: function () {
			        var self = this;
			        abp.ui.setBusy(self.$box);
			        var data = self.$form.serializeFormToObject();
			        self.service.updateUser(data)
                        .done(function () {
                            abp.message.success(self.localize("EditUserSucceed"))
                                .done(function () { location.href = "@Url.Action("list")"; });
                        })
                        .always(function () {
                            abp.ui.clearBusy(self.$box);
                        });
			    }
		    };

		    $(function() { (new $$$()).init(); });
	    }(jQuery);
    </script>
}
<ul class="content-nav">
    <li>
        <a href="@Url.Action("list")">@L("List")</a>
    </li>
    <li>
        <a href="@Url.Action("add")">@L("Add")</a>
    </li>
    <li class="active">
        <a href="javascript:;">@L("Edit")【@this.Model.UserName】</a>
    </li>
</ul>
<div class="box box-success box-edge-all" data-dock="true">
    <form role="form" class="col-xs-10">
        <div class="box-body">
            <input type="hidden" name="Id" value="@this.Model.Id" />
            <div class="form-group">
                <label>@L("UserName")</label>
                <input name="UserName" type="text" class="form-control" value="@this.Model.UserName" maxlength="@FutureUser.MaxUserNameLength" readonly>
            </div>
            <div class="form-group">
                <label>@L("LastName")</label>
                <input name="Surname" type="text" class="form-control" value="@this.Model.Surname" maxlength="@FutureUser.MaxSurnameLength" autofocus>
            </div>
            <div class="form-group">
                <label>@L("FirstName")</label>
                <input name="Name" type="text" class="form-control" value="@this.Model.Name" maxlength="@FutureUser.MaxNameLength">
            </div>
            <div class="form-group">
                <label>@L("EmailAddress")</label>
                <input name="EmailAddress" type="email" class="form-control" value="@this.Model.EmailAddress" maxlength="@FutureUser.MaxEmailAddressLength">
            </div>
        </div>
        <div class="box-footer">
            <a class="btn btn-primary" href="javascript:;" data-action="submit">
                <i class="fa fa-check"></i>
                @L("Submit")
            </a>
        </div>
    </form>
</div>